/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ifconnect.model.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;

/**
 *
 * @author Genemes
 */
@Entity
public class Curso implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @SequenceGenerator(name = "Curso_ID", sequenceName = "Curso_SEQUENCE", allocationSize = 1, initialValue = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "Curso_ID")
    private Long id;
    private String nome;
    private String categoria;
    private String area;
    private String descricao;
    @OneToMany(mappedBy = "curso", cascade = {CascadeType.ALL})
    private Collection<Disciplina> disciplinas = new ArrayList<Disciplina>();
    @ManyToOne
    private Campus campus;

    public Curso() {
    }

    public Curso(String nome, String categoria, String area, String descricao, Campus campus) {
        this.nome = nome;
        this.categoria = categoria;
        this.area = area;
        this.descricao = descricao;
        this.campus = campus;
    }

    public Curso(Campus campus) {
        this.campus = campus;
    }

    public boolean addDisciplina(Disciplina disciplina) {
        return this.disciplinas.add(disciplina);
    }

    public void removedisciplina(Disciplina disciplina) {
        this.disciplinas.remove(disciplina);
    }

    public Campus getCampus() {
        return campus;
    }

    public void setCampus(Campus campus) {
        this.campus = campus;
    }

    public Collection<Disciplina> getDisciplinas() {
        return disciplinas;
    }

    public void setDisciplinas(Collection<Disciplina> disciplinas) {
        this.disciplinas = disciplinas;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public String getCategoria() {
        return categoria;
    }

    public void setCategoria(String categoria) {
        this.categoria = categoria;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }
    
    

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Curso other = (Curso) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        if (this.disciplinas != other.disciplinas && (this.disciplinas == null || !this.disciplinas.equals(other.disciplinas))) {
            return false;
        }
        if (this.campus != other.campus && (this.campus == null || !this.campus.equals(other.campus))) {
            return false;
        }
        if ((this.nome == null) ? (other.nome != null) : !this.nome.equals(other.nome)) {
            return false;
        }
        return true;
    }


}
